package com.sugar.ssm.dto;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tangyx
 * @date 2022/3/29 22:42
 * +
 */
public class Msg {

    private int code;

    private String msg;

    private Map<String,Object> extend = new HashMap<>();

    public Map<String, Object> getExtend() {
        return extend;
    }

    public void setExtend(Map<String, Object> extend) {
        this.extend = extend;
    }

    public static Msg success(){
        return new Msg(100,"数据处理成功");
    }

    public static Msg wrong(){
        return new Msg(200,"服务器出了点问题，正在处理，稍后访问");
    }
    public Msg() {

    }

    public Msg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

//  类中的this指代的是当前对象
    public Msg add(String key,Object value) {
        this.getExtend().put(key,value);
        return this;
    }
}
